#include <stdio.h>
#include <stdlib.h>
#define MAXLEN 100
#define Data_type int

typedef struct stack
{
     int top;
     int maxLength;
     Data_type *data;
} stack;

// 创建顺序栈
stack *create_stack(int len)
{
     stack *s = (stack *)malloc(sizeof(stack));
     s->top = -1;
     s->maxLength = len;
     s->data = (Data_type *)malloc(sizeof(stack) * len);
}
int stack_empty(stack *s)
{
     if (s->top == -1)
     {
          return 1;
     }
     return 0;
}
// 判满
int stack_full(stack *s)
{
     if (s->top == s->maxLength)
     {
          return 1;
     }
     return 0;
}
// 入栈
int stack_push(stack *s, Data_type value)
{
     if (stack_full(s))
     {
          printf("栈已满\n");
     }
     s->top++;
     s->data[s->top] = value;
}

// 出栈
Data_type stack_pop(stack *s)
{
     if (stack_empty(s))
     {
          printf("栈数据为空\n");
     }
     Data_type value = s->data[s->top];
     s->top--;
     printf("出栈数据%d\t", value);
     return value;
}
// 销毁栈
int stack_destory(stack *s)
{
     if (!stack_empty(s))
     {
          free(s->data);
     }
     free(s);
     return 0;
}
// 清空栈
int stack_clear(stack *s)
{
     if (s == NULL)
     {
          printf("s is NULL\n");
     }
     s->data = NULL;
     s->top = -1;
     return 0;
}

void main()
{
     stack *s = create_stack(10);
     stack_push(s, 1);
     stack_push(s, 2);
     stack_push(s, 3);
     stack_push(s, 4);
     for (size_t i = 0; i < 1; i++)
     {
          stack_pop(s);
     }
     printf("\n");
}